<?php

/**
 * @filename functions.php 
 * @encoding UTF-8 
 * @author  fwz 
 * @datetime 2018-6-20  16:06:51
  */



function escape($input,$urldecode=0){
    if(is_array($input)){
        foreach($input as $key=>$val){
            $input[$key] = escape($input,$urldecode);
        }
    }else{
        $input = trim($input);
        
        if(strnatcasecmp(PHP_VERSION, '5.4.0') >= 0){
            $input = addslashes($input);
        }else{
            
            if(!get_magic_quotes_gpc()){
                $input = addslashes($input);
            }
        }
    }
    if(substr($input,-1,1) == '\\'){ $input = $input."'"; }
    
    return $input;
}